// components/Pickers/pickers.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    dataList: {
      type: Array,
      default: []
    }, 
    title: {
      type: String,
      default: ''
    },
    isRequired: {
      type: Boolean,
      default: true
    },
    value: {
      type: String,
      default: ''
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    index: ''
  },
  created(){
   this.getData()
  },
  observers: {
    'value': function(value) {
      this.getData(value)
    },
  },
  /**
   * 组件的方法列表
   */
  methods: {
    getData(value){
      let that = this
      console.log('this.data.value',this.data.value, this.data.isRequired)
      this.data.dataList.map((item, index) => {
        if(item.id == this.data.value){
          console.log('index',index)
          that.setData({
            index: index
          })
        }
      })
    },
    bindPickerChange(e){
      console.log(e)
      this.setData({
        index: e.detail.value
      })
      this.triggerEvent('confirmData', e.detail.value)
    },
  }
})
